<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/base.jsp"%>
<%@ include file="/module/taglibs.jsp"%>
<%@ include file="/module/nocache.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>业余团校管理</title>
<%@ include file="/module/js.jsp"%>
</head>
<body>
	<form action="#" name="Form" id="Form" method="post">
		<input type="hidden" name="idList" id="idList"/>
		<input type="hidden" id="bodyData" name="bodyData" value=""/>
	<%@ include file="/module/orderField.jsp"%>
		<table cellpadding="1" cellspacing="1" border="0">
			<tr>
				<td><input type="button" id="btnQuery" value="查询"
					class="inputButton" /></td>
				
		       <kl:permission permisstionList="${permisstionList}" currentUser="${_login_console_user}" currentCatalogId="<%=CatalogUtils.getCatalogId(\"ZHDJ_YYTX_TXGL\")%>" key="add">		
				<td><input type="button" id="btnAdd" value="添 加" 
					class="inputButton" /></td>
					</kl:permission>
				<kl:permission permisstionList="${permisstionList}" currentUser="${_login_console_user}" currentCatalogId="<%=CatalogUtils.getCatalogId(\"ZHDJ_YYTX_TXGL\")%>" key="delete">			
				<td><input type="button" id="btnDelete" value="删除"
					 class="inputButton"/></td>
			    </kl:permission>
			    <td><input type="button" id="btnExport" value="导出"
					 class="inputButton"/></td>
					 
			</tr>
		</table>
		<table cellpadding="1" cellspacing="1">
			<tr>
				<td>团校期数：</td>
				<td><input type="text" id="dxqs" name="dxqs"   placeholder="请输入"   autocomplete="off" class="inputText" /></td>
				<td>授课主题：</td>
				<td><input type="text" id="skzt" name="skzt"   placeholder="请输入"   autocomplete="off" class="inputText" /></td>
			</tr>
		</table>
		</br>
	     <table id="dg"   style="width:100%;"
			data-options="pagination:true,collapsible:true,url:'${basePath}/communityAmateurSchool/List',method:'post',remoteSort:true">
			<thead>
				<tr>
					<th data-options="field:'dxid',checkbox:true,width:10,align:'left'"></th>
					<th data-options="field:'dxqs',nowrap:true,width:220,align:'left',sortable:true,formatter:formater">团校期数</th>
					<th data-options="field:'skzt',nowrap:true,width:350,align:'left',sortable:true">授课主题</th>
					<th data-options="field:'sksj',nowrap:true,width:180,align:'left',sortable:true">授课时间</th>
					<th data-options="field:'skdd',nowrap:true,width:350,align:'left',sortable:true">授课地点</th>
					<th data-options="field:'jhcyrs',nowrap:true,width:150,align:'left',sortable:true">计划参与人数</th>
					<th data-options="field:'sjskrs',nowrap:true,width:150,align:'left',sortable:true">实际授课人数</th>
					<th data-options="field:'createtime',nowrap:true,width:170,align:'left',sortable:true,formatter:formatDate">创建时间</th>
				</tr>
			</thead>
		</table>
</form>	
		

		<script type="text/javascript">
		  
		  function formater(value, row, index) {
				return "<a href='${basePath}/communityAmateurSchool/details?id=" + row.dxid + "'>" + value + "</a>";
			}
	
	    	 function formatDate(value,row, index){
			    	if(value!=null){
			    		var date=new Date(value);
						var y = date.getFullYear();
						var m = date.getMonth()+ 1;
						var d = date.getDate();
						var h= date.getHours();       //获取当前小时数(0-23)
						var mm= date.getMinutes();     //获取当前分钟数(0-59)
						var s= date.getSeconds();     //获取当前秒数(0-59)
					 	var data = y +'-'+(m <10?('0'+ m):m)+'-'+(d <10?('0'+ d):d)+'';
						return data;
			    	}else{
			    		return "";
			    	}
				}
	    	
		    
			$(document).ready(
							function() {
					         	$('#dg').datagrid({
								 /*   onSortColumn :function(sort,order){
								   var _sort=sort;
								   var _order=order;
								   var options=$('#dg').datagrid('getPager').data("pagination").options;
								   var page=options.pageNumber;
								   var pageSize=options.pageSize;
								   window.setTimeout(function(){
									   $.post("${basePath}/communityAmateurSchool/List",{orderFlag:_order,orderField:_sort,
										    dxqs:$('#dxqs').val(),
											skzt:$('#skzt').val()},
											function(data){
												  $('#dg').datagrid("loadData",data); 
											   });
											   },100);  
								   },
								   rowStyler: function(index,row){
								   }, */
								   
								});
					      	   
					         	
					         	
								//查询
								$('#btnQuery')
										.click(
												function() {
													$('#dg').datagrid('load',{
														    dxqs: $('#dxqs').val(),
															skzt: $('#skzt').val()
													});
												});
							
								$('#btnAdd').click(function() {
									   window.location.href = "${basePath}/communityAmateurSchool/addInInt";
								});

								
								$('#btnExport').on('click', function(){
									   layer.confirm("您确定要导出吗?", {icon: 3, title:'提示',skin:'layer-ext-moon'}, function(index){
										   var rows = $("#dg").datagrid("getRows");
										        $("#bodyData").val(JSON.stringify(rows));
											    document.Form.action = "${basePath}/communityAmateurSchool/export";
												document.Form.submit();
												layer.close(index);
					            		 });
									});
								
							
								
								$('#btnDelete').click(function() {
									               $("#idList").val("");
													var count = 0;
													var idList = new Array();
												    var sels = $("#dg").datagrid("getSelections");
											    	for(var i in sels){
											    		idList.push(sels[i].dxid);
											    		count++;
											    	}
													if (count == 0) {
														layer.alert("您至少选择一条删除记录信息", {icon: 3});
														return false;
													}else{
														  layer.confirm("您是否删除当前选中数据信息", {icon: 3, title:'提示',skin:'layer-ext-moon'}, function(index){
															    $("#idList").val(idList);
															    document.Form.action = "${basePath}/communityAmateurSchool/delete";
																document.Form.submit();
														  },function(index){
																layer.close(index);
														  });
													}
												});
						     	});
			
			  if("${msg}"!=""){
			       layer.alert("${msg}", {icon: 6});
			  }  
		</script>
</body>
</html>
